<%@page import="com.is.control.ParamClassControl"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="com.is.model.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="com.is.model.Student"%>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="com.is.control.DictationControl"%>
<%@page import="com.is.control.ParamStuyearControl"%>
<%@page import="com.is.control.ParamCourseControl"%>
<%@page import="com.is.control.DictationTimeControl"%>
<%@page import="com.is.util.DesData"%>
<%@page import="com.is.util.DateTime"%>
<%@page import="com.is.model.ParamStuyear"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/InterStu/resources/image/favicon.ico" />
<link rel="stylesheet" type="text/css" href="../../resources/css/all.css" />
<script type="text/javascript" src="../../resources/js/jquery-1.8.1.js"></script>
<script type="text/javascript" src="../../resources/js/WebCalendar.js"></script>
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resources/js/jquery.artDialog.js"></script>
<script type="text/javascript" src="../../resources/js/iframeTools.js"></script>
<script type="text/javascript">
	$(function(){
		var block = $("#magic_block");
		if($(".active a").position()){
			block.css("top",$(".active a").position().top+10)
			.data("oriTop",$(".active a").position().top)
		}
		$(".nav ul li").find("a").hover(
			function(){
				var $this = $(this);
				var newTop = $this.position().top;
				block.stop().animate({
					top:newTop+10
				})
			},
			function(){
				block.stop().animate({
					top:block.data("oriTop")+10
				})
			}
		)
		var h = $(".right").height();
		$(".left").height(h);
		$(".update").click(function(){
			$.dialog.open("/InterStu/update_info.jsp",{width:460,height:400,title:"个人信息"});
		})
		$('img').error(function(){
			this.src = "/InterStu/resources/image/man.GIF";
		})
		$(".allCourses").click(function(){
			var url = $(this).attr("rel");
			$.dialog.open(url,{width:460,height:'auto'});
		})
		$("[name='stuyear']").change(function(){
			var selectYear = $(this).val();
			$.ajax({
				type:"post",
				dataType:"html",
				url:"../homework/select_option.jsp",
				data:{
					stuYearId:selectYear
				},
				cache:false,
				success:function(data){
					$("[name='courseClassId']")[0].options.length = 0;
					$("[name='courseClassId']").append(data);
				}
			})
		})
	})
	
	
	
	function doSubmit(){
      var submit = document.getElementById("submit");
      submit.disabled="disabled";
      return true;
}

	
</script>
<title>留学生预科班</title>
</head>
<body>
<%
		User cu = (User)session.getAttribute("user");
%>
<div class="header">
	<div class="title pr">
    	<a href="javascript:void(0);"><span class="update pa">个人信息</span></a>
        <span class="logout pa"><a class="hide" href="/InterStu/login/logout.jsp">退出</a></span>
    </div>
</div>
<div class="main">
	<div class="left">   
		<div class="infomation">
			<div class="photo">
			<%
			String picUrl = cu.getPicUrl();
			if(session.getAttribute("picUrl")!=null){
			    picUrl = "/InterStu/User/UserHeadImage/"+(String)session.getAttribute("picUrl");
			}	
			System.out.print(picUrl);
			%>
				<img width='60' height="60" src = "<%=picUrl %>"  />
			</div>
			<div class="welcome">
				<%=cu.getName() %>,<br/>
				欢迎您使用！
			</div>
		</div>   	
    	<div class="nav">
        	<ul>	
        		<li class="pa" id="magic_block"></li>
            	<%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/stuyear/stuyear_start.jsp">新学期设置</a></li>
                <li><a href="/InterStu/pages/users/user_all.jsp">用户管理</a></li>
                <%} %>
                <li><a href="/InterStu/pages/students/student_add.jsp">学生管理</a></li>
                <li class="active"><a href="/InterStu/pages/dictation/dictation_add.jsp">学生考核</a></li>
                <%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/assess/teacher_assess.jsp">教职人员管理</a></li>
                <%} %>
            </ul>
        </div>
    </div>
    <div class="right">
    	<div class="r1">
    	<table class="dictations tab">
	    <tr>
	    	<td>
	    		<a class="current" href="/InterStu/pages/dictation/dictation_add.jsp">听写成绩</a>
			</td>
			<td>
				<a href="/InterStu/pages/homework/homework_add.jsp">作业成绩</a>			
			</td>
			<td>
				<a href="/InterStu/pages/courseScore/score_go.jsp">成绩录入</a>
			</td>
			 <%if(cu!=null&&cu.getRole().equals("1")){ %>
			<td>
				<a href="/InterStu/pages/evaluation/students_all.jsp">综合评价</a>
			</td>
			<%} %>
	    </tr>
	    </table>
	    <%
	    DesData des = new DesData();
        int courseClassId = Integer.parseInt(des.decrypt(ParamUtil.getString(request,"courseClassId","4d3d3f222d4c6e08")));//默认为0
        //System.out.print(courseClassId);
        String time1 = DateTime.SimpleDate();
        String time2 = DateTime.SimpleDate();
 	   int stuyear = ParamStuyearControl.getCurrentStuyearId();
 	   int usingStuyear = ParamUtil.getInt(request,"stuyear",stuyear);
 	    session.setAttribute("stuYearId",usingStuyear);
 	   ParamStuyear usingPS = ParamStuyearControl.getStuyear(usingStuyear);
 	   if(stuyear!=0&&usingPS!=null){
 	        time1 = ParamUtil.getString(request,"time1",usingPS.getStartTime());//默认为本学期开学时间
 	     }
 	   if(stuyear==usingStuyear){
 	        time2 = ParamUtil.getString(request,"time2",DateTime.SimpleDate());
 	   }else{
 		    time2 = usingPS.getEndTime();
 	   }
		List<CourseClass> ccs = null;
		int stuYear = (Integer)session.getAttribute("stuYearId");
		if(cu!=null&&cu.getRole().equals("1")){
			   //管理员应该能查看所有的课程班级出勤情况
			  ccs = CourseClassControl.getAllCourseClassIdByUidAndStuyear(0,stuYear);
		}
		if(cu!=null&&cu.getRole().equals("0")){
			   //任课教师看到自己所带课程的出勤情况
			   ccs = CourseClassControl.getAllCourseClassIdByUidAndStuyear(cu.getId(),stuYear);
		}
		if(ccs==null||ccs.size()==0){
			   out.print("本学期尚未有任何课程教学工作。");
		}else{
			%>
	     <form action="dictation_statistics.jsp" method="post">
		   <table class="table">
		   <caption>请选择</caption>
		   <tr>
		    <td>学期</td>
	   <td><select name="stuyear" style="width: 100px;">
	   <%
	    List<ParamStuyear> stuyears = ParamStuyearControl.getAllStuyear();
	     for(ParamStuyear ps:stuyears){
	    	 %>
	    	 <option value="<%=ps.getId() %>"  <%if(ps.getId()==stuyear)out.print("selected"); %>><%=ps.getStuyear() %></option>
	    	 <%
	     }
	   %>
	   </select></td>
		   <td>
		   <select name="courseClassId" style="width: 100px;">
		   <%
		      for(CourseClass cc:ccs){
		   %>
		   <option value="<%=des.encrypt(String.valueOf(cc.getId())) %>" <%if(cc.getId()==courseClassId) out.print("selected='selected'");%>><%=ParamClassControl.getClassName(cc.getClassId()) %><%=ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName() %></option>
		   <%} %>
		   </select>
		   </td>
			<td>开始时间</td>
			<td><input id="time1" type='text'  name="time1" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer"  value="<%=time1 %>"/></td>
	        <td>结束时间</td>
			<td><input id="time2" type='text'  name="time2" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="cursor:pointer"  value="<%=time2 %>"/></td>
	       <td><input type="submit" value="确定"/></td>
	       </tr>
	       </table>
		   </form>
	    </div>
			   <%
		   }
     
 %>
 <%//System.out.print(classId+"DDDD"+courseId); %>
 <%
    if(courseClassId>0){
    	CourseClass cc = CourseClassControl.getCourseClassById(courseClassId);
    	String courseName = ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName();
    	String className = ParamClassControl.getClassName(cc.getClassId());
   
 %>
 <div class="r2">
 <form>

<table class="table">
<caption><%=className %><%=courseName %>此期间内已经听写<%=DictationTimeControl.getCount(courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %>次。  
</caption>
<thead>
<tr>
	<th>姓名</th>
	<th>A</th>
	<th>B</th>
	<th>C</th>
	<th>D</th>
</tr>
</thead>
<tbody>
<%
     List<Student> students = StudentControl.getAllStudentMulti("","","",String.valueOf(cc.getClassId()),"","","","");
     for(Student s:students){
     %>
     <tr>
     <td><a class="allCourses" href="javascript:void(0);" rel="allCoursesOneStu.jsp?stuId=<%=des.encrypt(String.valueOf(s.getId())) %>"><%=s.getChineseName() %></a></td>
     <td><%=DictationControl.getCount(s.getId(),"A",courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %></td>
     <td><%=DictationControl.getCount(s.getId(),"B",courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %></td>
     <td><%=DictationControl.getCount(s.getId(),"C",courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %></td>
     <td><%=DictationControl.getCount(s.getId(),"D",courseClassId,ParamStuyearControl.getCurrentStuyearId(),time1,time2) %></td>
     </tr>
     <%
     }
 %>
 </tbody>
</table>
</form>
<%}else{} %>
</div>
</div>
</div>
<div class="footer">
	<p>版权所有：东北师范大学留学生预科部&nbsp;&nbsp;  蓝旭工作室开发</p>
</div>
</body>
</html>